﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using GroundWater.BusinessActions;

using UserTable = GroundWater.Data.UserDataSet.UsersDataTable;
using UserRow = GroundWater.Data.UserDataSet.UsersRow;


//using MonitoringTable = GroundWater.Data.MonitoringDataSet.MonitoringDataTable;
//using MonitoringRow = GroundWater.Data.MonitoringDataSet.MonitoringRow;

namespace GroundWater.Admin
{
    public partial class ChangePassword : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SiteUtil.Validate(this, "更改口令");
        }

        protected void btnLogIn_Click(object sender, EventArgs e)
        {
            string userId = HttpContext.Current.User.Identity.Name;

            UserRow row = GroundWater.BusinessActions.Users.GetById(userId, false);
            if (row != null)
            {
                if (row.Password == txtOld.Text.Trim())
                {
                    row.Password = txtNew.Text.Trim();
                    Users.Update(row.Table.DataSet, false, true, new string[] { "Users" });

                    lblJavaScript.Text = "<script type=\"text/javascript\">alert('修改密码成功。');</script>";
                }
                else
                {
                    lblJavaScript.Text = "<script type=\"text/javascript\">alert('您提供的原来密码不正确。');</script>";
                }
            }

            
        }
    }
}
